package org.martin.snsrs.client.services.http;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.json.JSONException;
import org.json.JSONObject;
import org.martin.snsrs.client.manager.Session;

public class SnsrsApi {
	
	private static final String DEFAULT_BASE_URL="http://192.168.0.107:8080/SnsRS/";
	
	private Api api;
	
	public SnsrsApi(Api api){
		this.api = api;
	}
	
	public boolean publishNewActivity(){
		return true;
	}
	
	public JSONObject login(String username, String pasword) throws Exception{
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("username", username);
		map.put("password", pasword);
		return api.get(api.getURL("login", map));
	}
	
	public JSONObject publishNewActivity(String activityName,
			String startDate, String endDate,
			String activityLocation, String activityDesc,
			File image) throws Exception{
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("activityName", activityName);
		map.put("activityStartTime", startDate);
		map.put("activityEndTime", endDate);
		map.put("activityLocation", activityLocation);
		map.put("activityDesc", activityDesc);
		RequestParams params = new RequestParams();
		params.put("activityPic", image);
		return api.post(api.getURL("addNewActivity", map),params);
	}
}
